package com.example.demo.controller;

import com.example.demo.entity.ApiRequestResult;
import com.example.demo.entity.ResponseInfo;
import com.example.demo.service.ApiRequestResultService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@Validated
@RequestMapping("/apiRequestResult")
@io.swagger.annotations.Api(value = "/apiRequestResult", tags = "api执行结果接口")
public class ApiRequestResultController {

    @Resource
    ApiRequestResultService apiRequestResultService;


    /**
     * @param planLogId     任务日志主键
     * @param apiTestCaseId 测试用力主键
     * @return 返回接口结果集合
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取api结果列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "planLogId", value = "日志id", required = true, dataType = "int"),
            @ApiImplicitParam(name = "apiTestCaseId", value = "测试用例id", required = true, dataType = "int")
    })
    public ResponseInfo<List<ApiRequestResult>> getApiResultList(@RequestParam int planLogId, @RequestParam int apiTestCaseId) {
        return ResponseInfo.successInfo(apiRequestResultService.getList(planLogId, apiTestCaseId));
    }
}
